package cn.uexpo.lhz.controller.admin;

import cn.uexpo.lhz.common.oldUtils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.uexpo.lhz.biz.CamerastatusBiz;
import cn.uexpo.lhz.common.oldBase.BaseController;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.core.http.HttpResult;
import cn.uexpo.lhz.domain.Camerastatus;
import cn.uexpo.lhz.domain.CamerastatusExample;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 *
 * @ClassName:  CamerastatusController
 * @Description:TODO(摄像头：状态)
 * @author: 李冬建
 * @date:   2020年6月4日 上午10:26:19
 * @Copyright:  1.0.0
 */
@RestController
@RequestMapping("/cert/status")
public class CamerastatusController extends BaseController<Camerastatus>{

	@Autowired
	private CamerastatusBiz camerastatusBiz;

	@GetMapping(value="/findPage")
	public HttpResult findPage(@RequestParam Map<String, Object> params) {
		PageResult result=findPage1(params);
		return HttpResult.ok(result);
	}


	private PageResult findPage1( Map<String, Object> params) {


		String page =  (String)params.get("page");
		String limit =  (String)params.get("limit");

		PageRequest request = new PageRequest();
		request.setPage(Integer.parseInt(page));
		request.setLimit(Integer.parseInt(limit));

		String extstr1 = (String)params.get("extstr1");//摄像头名称
		String eqpname = (String)params.get("eqpname");//设备名称

		CamerastatusExample example=new CamerastatusExample();
		String orderBy=" createTime ";//默认按照时间降序
	    String sort=" desc ";//默认按照时间降序
		example.setOrderByClause(orderBy+sort);
		CamerastatusExample.Criteria citeria=example.createCriteria();
		if (StringUtils.isNotBlank((String)extstr1)) {
			citeria.andExtstr1Like("%"+(String)extstr1+"%");
		}
		if (StringUtils.isNotBlank((String)eqpname)) {
			citeria.andEqpnameLike("%"+(String)eqpname+"%");
		}
		PageResult result=camerastatusBiz.findPage(request,example);
		return result;
	}

}
